<template>
  <div class="home">
    <div>商家管理后台</div>
    <div>
          <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
            <el-tab-pane label="商家信息" name="first"></el-tab-pane>
            <el-tab-pane label="产品列表" name="second"></el-tab-pane>
            <el-tab-pane label="重置密码" name="third"></el-tab-pane>
            <el-tab-pane label="订单列表" name="fourth"></el-tab-pane>
            <el-tab-pane label="销售统计" name="fourth"></el-tab-pane>
          </el-tabs>
    </div>
    <div>
        <router-view></router-view>
    </div>
  </div>
</template>

<script>
// @ is an alias to /src


export default {
  name: 'Home',
  data() {
      return {
          activeName: 'first',
          user: null
      }
  },
  mounted() {
      let token = window.sessionStorage.getItem('token')
      if(token == null) {
          this.$router.push('/login')
          return
      }
      // 保存当前登录用户信息
      this.user = window.sessionStorage.getItem('user')
  },
  methods: {
      handleClick(tab, event) {
          console.log(this.activeName, tab, event);
          if(this.activeName == 'first') {
              this.$router.push('/index/seller')
          }
          else if(this.activeName == 'second') {
              console.log('second');
              // this.$router.push('/index/product')
          }
          else if(this.activeName == 'third') {
              console.log('third');
              // this.$router.push('/index/reset')
          }
          else if(this.activeName == 'fourth') {
              console.log('second');
              // this.$router.push('/index/admin')
          }
      }
  }

}
</script>
